<template>
  <div class="status-panel">
    <h3 class="title">{{ title }}</h3>
    <div class="stats-container">
      <div v-for="(stat, index) in stats" :key="index" class="stat-item">
        <span class="value">{{ stat.value }}</span>
        <span class="label">{{ stat.label }}</span>
      </div>
    </div>
    <img class="status-icon" :src="getImg(icon)" alt="" />
  </div>
</template>

<script setup>
defineProps({
  icon: { type: String, required: true },
  title: {
    type: String,
    required: true,
  },
  stats: {
    type: Array,
    required: true,
    validator: (stats) => stats.every((stat) => stat.value && stat.label),
  },
});
const getImg = (url) => {
  return new URL(`../../../assets/warning/${url}.svg`, import.meta.url).href;
};
</script>

<style lang="scss" scoped>
.status-panel {
  background-color: #fff;
  border-radius: 4px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid #eaeaea;
  height: 100%;
  position: relative;
  .title {
    margin: 0 0 40px;
    font-size: 16px;
    color: #333;
    font-weight: 500;
  }

  .stats-container {
    display: flex;
    justify-content: space-between;
    gap: 8px;

    .stat-item {
      text-align: center;
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      .value {
        font-weight: 400;
        font-size: 30px;
        color: #000000;
        line-height: 35px;
        margin-right: 2px;
      }

      .label {
        font-weight: 400;
        font-size: 14px;
        color: #999999;
        line-height: 16px;
      }
    }
  }
  .status-icon {
    position: absolute;
    bottom: 5px;
    right: 6px;
  }
}
</style>